/*
 ------------------------------------------------------------------------------
 Copyright (C) 2013 Eternal Games.

 This file is part of the EternalTech source code.

 The EternalTech source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The EternalTech source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the EternalTech source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


//
// cg_serverCommands.cpp - executes a string command from the server-game
//


#include "cg_local.h"


/*
 ==================
 CG_ConfigStringCommand
 ==================
*/
static void CG_ConfigStringCommand (){

	int		index;

	index = Str_ToInteger(glqCmdSystem->Argv(1));

	if (index < 0 || index >= MAX_CONFIG_STRINGS){
		G_Printf("Bad config string index (%i)\n", index);
		return;
	}

	// Update the config string
	CG_SetConfigString(index, glqCmdSystem->Args(2, -1, false));
}

/*
 ==================
 
 ==================
*/
static void CG_ChatCommand (){

	// TODO: add to the chat HUD GUI

	G_Printf("%s\n", glqCmdSystem->Args(1, -1, false));
}

/*
 ==================
 CG_ServerCommand
 ==================
*/
void CG_ServerCommand (){

	const char	*name;

	name = glqCmdSystem->Argv(0);

	if (!Str_ICompare(name, "cs"))
		CG_ConfigStringCommand();
	else if (!Str_ICompare(name, "chat"))
		CG_ChatCommand();
	else
		G_Printf("Unknown server command \"%s\"\n", name);
}